#include <stdio.h>
#define N 200
#define M 10

int main()
{
	int PerfectNumbers[N];//用于保存找到的完数
	int ArrNumbers[N][M];//用于保存找到的完数的因子
	for (int a1 = 0; a1 <= N - 1 ; a1++)
	{
		PerfectNumbers[a1] = 0;
		for (int j1 = 0; j1 <= M - 1; j1++)
		{
			ArrNumbers[a1][j1] = 0;
		}
	}
	//寻找一个自然数的因子
	int PerfectNumberIndex = 0;
	for (int num = 1; num <= N ; num++)
	{
		int factorIncex = 0;
		int factors[M];
		for (int k1 = 0; k1 <= M - 1; k1++)
		{
			factors[k1] = 0;
		}
		int sum = 0;
		for (int  k = 1; k <= num - 1; k++)
		{
			if (num % k == 0)
			{
				factors[factorIncex] = k;
				factorIncex = factorIncex + 1;
				sum = sum + k;
			}
		}
		if (num == sum)
		{
			PerfectNumbers[PerfectNumberIndex] = num;
			for (int k = 0; k <= M - 1; k++)
			{
				ArrNumbers[PerfectNumberIndex][k] = factors[k];
			}
			PerfectNumberIndex++;
		}
	}
	//print
	for (int a2 = 0; a2 <= N - 1 ; a2++)
	{
		if (PerfectNumbers[a2] != 0)
		{
			printf("%d的因子：", PerfectNumbers[a2]);
			for (int b2 = 0; b2 <= M - 1; b2++)
			{
				if (ArrNumbers[a2][b2] != 0)
					printf("%3d", ArrNumbers[a2][b2]);
			}
			printf("\n");
		}
	}
	return 0;
}
